/**
 * ============================================================================
 *
 * Copyright (C) 2012 Android MySportactivities Systems.  All rights reserved. The content 
 * presented herein may not, under any circumstances, be reproduced, in 
 * whole or in any part or form, without written permission from 
 * MySportactivities Systems.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are NOT permitted. Neither the name of MySportactivities Systems,
 * nor the names of contributors may be used to endorse or promote products 
 * derived from this software without specific prior written permission.
 *
 * ============================================================================
 *
 * Author: tuan
 *  
 *
 * Revision History
 * ----------------------------------------------------------------------------
 * Date                Author              Comment, bug number, fix description
 *
 * Apr 4, 2012      tuan@edge-works.net           version 1.0
 *
 * ----------------------------------------------------------------------------
 */
package com.stryker.network;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

// TODO: Auto-generated Javadoc
/**
 * Created on Apr 4, 2012.
 * 
 * @author tuan
 * @version 1.0
 * @copyright Copyright (c) Android MySportactivities Systems, all rights
 *            reserved
 */
public class UltilitiesNetwork {

	/**
	 * Soap for check login.
	 * 
	 * @param METHOD_NAME
	 *            the mETHO d_ name
	 * @param SOAP_ACTION
	 *            the sOA p_ action
	 * @param NAMESPACE
	 *            the nAMESPACE
	 * @param URL
	 *            the uRL
	 * @param params
	 *            the params
	 * @return the soap object
	 */
	public SoapObject soapForCheckLogin(String METHOD_NAME, String SOAP_ACTION,
			String NAMESPACE, String URL, String[] params) {
		SoapObject result = null;
		try {
			SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
			if (params.length > 0) {
				request.addProperty(params[0], params[1]);
				request.addProperty(params[2], params[3]);
			}
			SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
					SoapEnvelope.VER11);
			envelope.dotNet = true;
			envelope.setOutputSoapObject(request);

			HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
			androidHttpTransport.call(SOAP_ACTION, envelope);

			result = (SoapObject) envelope.getResponse();

		} catch (Exception e) {
			e.getMessage();
			e.printStackTrace();
		}
		return result;
	}
	
	public SoapObject soapForGetAllProjectNew(String METHOD_NAME, String SOAP_ACTION,
			String NAMESPACE, String URL, String[] params) {
		SoapObject result = null;
		try {
			SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
			if (params.length > 0) {
				request.addProperty(params[0], params[1]);
				request.addProperty(params[2], params[3]);
				
				request.addProperty(params[4], params[5]);
				request.addProperty(params[6], params[7]);
				
				request.addProperty(params[8], params[9]);
				request.addProperty(params[10], params[11]);
			}
			SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
					SoapEnvelope.VER11);
			envelope.dotNet = true;
			envelope.setOutputSoapObject(request);

			HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
			androidHttpTransport.call(SOAP_ACTION, envelope);

			result = (SoapObject) envelope.getResponse();

		} catch (Exception e) {
			e.getMessage();
			e.printStackTrace();
		}
		return result;
	}
}
